
<script setup lang="ts">
import type { ChatMessage } from "@/types";
import { ref, watch, nextTick, onMounted } from "vue";
import { chat } from "@/libs/gpt";
import cryptoJS from "crypto-js";
import Loding from "@/components/Loding.vue";
import Copy from "@/components/Copy.vue";
import { md } from "@/libs/markdown";
import { FunctionModel } from "@/model/function_model/FunctionModel"
import { Funds } from "@icon-park/vue-next";
import router from "@/router";
import GaNavigationBar from "@/components/GaNavigationBar.vue";
import DiaryEditView from "@/components/DiaryEditView.vue";
import TopView from "@/components/TopView.vue";
import DiaryListView from "@/components/DiaryListView.vue";
import type { RouteRecordNormalized } from "vue-router";
import { GlobalTool } from "@/utils/GlobalTool"
import { DiaryUnitVData } from "@/vdata/DiaryUnitVData";
import { GaRequestManager, GaRequestConfig, GaRequestMethod, GaRequestBodyInputType, GaResponseBodyOutputType } from "ga_utility_sdk_base";
import type { DiaryUnitModel } from "@/model/DiaryUnitModel";
import { ModelTransformer } from "@/transformer/ModelTransformer";
let arr: DiaryUnitVData[] = [];
arr = DiaryUnitVData.getTestData();
let ref_arr = ref(arr);
function onSave() {
    let unit0: DiaryUnitVData = ref_arr.value[0];
    let model: DiaryUnitModel = ModelTransformer.getDiaryUnitModel(unit0, 1);
    let config = new GaRequestConfig(GaRequestMethod.POST, GaRequestBodyInputType.OBJ_2_JSON, GaResponseBodyOutputType.BLOB_2_JSONOBJ);
    config.requestBodyInput = model;
    config.requestHeaders = {
        Authorization: "eyJ0eXBlIjoiSldUIiwiYWxnIjoiSFMyNTYiLCJ0eXAiOiJKV1QifQ.eyJ1c2VyTmFtZSI6Ikdpa2tpQXJlcyIsImV4cCI6MTcwNDEzMTM1OSwidXNlcklkIjoxfQ.w7RVvds3gdYq1_ix-ej6efNsbCN85iycTBtnUYsfDuw"
    }
    config.setRequestUrl("apiA/DiaryUnit/Insert");
    console.log(JSON.stringify(ref_arr.value));
    GaRequestManager.sharedInstance().invokeRequest(config, (status, res, msg, info) => {
        if (res) {
            console.log(res);
        }
    });
}

function logout() {
    router.back();
}
function onUser() {
    router.push("02-api_test/01-user");
}
function onDiary() {
    router.push("02-api_test/04-diary");
}
function onDiaryUnit() {
    router.push("02-api_test/03-diary_unit");
}
function onNote() {
    router.push("02-api_test/05-note");
}
function onCategory() {
    router.push("02-api_test/02-category");
}
</script>

<template>
    <div class="common-layout">
        <el-container>
            <el-header>
                <TopView @onSave="onSave"></TopView>
            </el-header>
            <el-container>
                <el-aside width="200px">
                    <DiaryListView></DiaryListView>
                </el-aside>
                <el-main>
                    <DiaryEditView :diaryUnits="ref_arr"></DiaryEditView>
                </el-main>
            </el-container>
        </el-container>
        <el-row><el-button @click="onUser">User</el-button></el-row>
        <el-row><el-button @click="onCategory">Category</el-button></el-row>
        <el-row><el-button @click="onDiaryUnit">DiaryUnit</el-button></el-row>
        <el-row><el-button @click="onDiary">Diary</el-button></el-row>
        <el-row><el-button @click="onNote">Note</el-button></el-row>
        <el-row><el-button @click="logout">Logout</el-button></el-row>
    </div>
</template>




<style scoped>
pre {
    font-family: -apple-system, "Noto Sans", "Helvetica Neue", Helvetica,
        "Nimbus Sans L", Arial, "Liberation Sans", "PingFang SC", "Hiragino Sans GB",
        "Noto Sans CJK SC", "Source Han Sans SC", "Source Han Sans CN",
        "Microsoft YaHei", "Wenquanyi Micro Hei", "WenQuanYi Zen Hei", "ST Heiti",
        SimHei, "WenQuanYi Zen Hei Sharp", sans-serif;
}

.btn {
    margin: 5px;
}
</style>